<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/12/14
 * Time: 16:04
 */

namespace app\admin\controller;



use app\admin\model\MemberUser;

class MemberController extends BaseController
{

    //视图实例化
    public function memberList(){
        return $this->fetch();
    }

    public function memberData($page,$limit){
        $where = input('param.username')?[['wx_nickname','like','%'.input('param.username').'%']]:'';
        $data = MemberUser::where($where)->order('status desc,create_time asc')->page($page,$limit)->select()->toArray();
        foreach($data as $k=>$v){
            $ret = MemberUser::where('id',$v['pid'])->field('wx_nickname')->find();
            if ($ret){
                $data[$k]['pid'] = $ret['wx_nickname'];
            }else{
                $data[$k]['pid'] = '空';
            }
        }
        //数据的总个数
        $count = MemberUser::count();
        $res = [
            'code'=>0,
            'msg'=>'返回成功',
            'count'=>$count,
            'data'=>$data
        ];
        return json($res);
    }
}